package com.gitee.wsl.ext.string

import kotlin.random.Random


/** Creates a random string of the specified [length] made up of the specified [allowedCharacters]. */
fun randomString(
    length: Int = 16,
    vararg allowedCharacters: Char = (('0'..'9') + ('a'..'z') + ('A'..'Z')).toCharArray()
): String = buildString(length) { repeat(length) { append(allowedCharacters[Random.nextInt(0, allowedCharacters.size)]) } }
